<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>商品内容页</title>	
	<link rel="stylesheet" href="http://localhost/Gshop/template/css/head.css"  type="text/css" />
	<script type="text/javascript" src='http://localhost/Gshop/template/js/jquery-1.7.2.min.js'></script>
	<script type="text/javascript" src="http://localhost/Gshop/template/js/spec.js"></script>
	<link rel="stylesheet" href="http://localhost/Gshop/template/css/content.css" />
	<script type='text/javascript' src='http://localhost/Gshop/hdphp/hdphp/Extend/Org/Jquery/jquery-1.8.2.min.js'></script>

	<script src="http://localhost/Gshop/template/js/content.js"></script>
	<style>
	.chose a{
		border:1px solid #ddd;
		color:black;
	}
 	a.active{
		border:1px solid red;
		color:red;
	 }
	 a.active:hover{
		border:1px solid red;
	 }
	 .num{
		border:1px solid grey;
		width:50px;
		height:20px;
	 }
	 .add{
	 	padding:0px 10px;
	 	font-size: 20px;
	 	cursor:pointer;
	 }
	 .del{
	 	padding:0px 10px;
	 	font-size: 18px;
	 	cursor:pointer;
	 }
	 input[name='num']{
	 	text-align: center;
	 }
	 .content{
	 	border:1px solid red;
	 	overflow: hidden;
	 	width:1210px;
	 	margin:0 auto;

	 }
	 .content .left{
	 	width:250px;
	 	border:1px solid blue;
	 	float: left;
	 	margin-left:10px;
	 }
	 .content .right{
	 	width:900px;
	 	float: right;
	 	font-family: tahoma,​arial,​宋体;
	 	color:#999;
	 	word-spacing: 6px;
	 	line-height: 20px;
	 }
	.content .right .top{
		height:50px;
		text-align: center;
		line-height: 50px;
		font-size: 25px;
		color:#000;
	}
	</style>
</head>
<body>
	<script>
	function searchAttr(obj){
	$(obj).parents("p").find("a").removeClass("active");
	$(obj).addClass("active");

	var attr='';
	$("a[attr][class='active']").each(function(){
		attr+=$(this).attr("attr")+'-';
	})
	attr=attr.slice(0,-1);

	gid=<?php echo $_GET['gid'];?>
	// 发送ajax请求库存的id,然后记录购物车
	$.post("<?php echo U('getStock');?>",{attr:attr,gid:gid},function(state){
		if(state==1){
			url="http://localhost/Gshop/index.php/Index/Index/content/gid=<?php echo $_GET['gid'];?>&spec="+attr;
			location.href=url;
		}else{
			alert("暂时没有货了！！！");
		}
	})
}
	</script>
<!-- 最顶部的可关闭广告 -->
<!-- <div id='top_ad'><img src="http://localhost/Gshop/template/images/top_ad.jpg" alt="" /></div> -->
<!-- 最顶部的可关闭广告结束-->
<!-- 头部灰色区域 -->
<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>京东首页</title>	
	<link rel="stylesheet" href="./css/head.css"  type="text/css" />
</head>
<body>
<!-- 最顶部的可关闭广告 -->
<!-- <div id='top_ad'><img src="./images/top_ad.jpg" alt="" /></div> -->
<!-- 最顶部的可关闭广告结束-->
<!-- 头部灰色区域 -->
	<div id="top">
		<div class="top_main">
			<!-- 左侧 -->
			<div class="top_l fl">
				<p class="didian"><span class='tu fl'></span><span class='wenzi fl'>北京</span> </p>
			</div>
			<!-- 左侧结束 -->
			<!-- 右侧 -->
			<div class="top_r fr ">
				<ul>
<!-- 头部记录用户是否已经登录开始 -->
			<?php if($_SESSION['user']){?>
					<li><span class='fl'>您好，</span>
						<span><?php echo $_SESSION['user']['uname'];?>！</span>
						<a href="<?php echo U('user/out');?>">退出</a>
					</li>
				<?php  }else{ ?>
					<li><span class='fl'>您好，欢迎来到京东！</span>
						<a href="<?php echo U('user/login',array('main'=>1));?>" class='fl'>[登录]</a> <a href="<?php echo U('user/reg',array('main'=>1));?>" class="denglu fl">[免费注册]</a> <span class='xian fl'>|</span>
					</li>
			<?php }?>
					<li><a href="<?php echo U('Member/index');?>" class="dingdan fl">我的订单</a><span class='xian fl'>|</span></li>
<!-- 头部记录用户是否已经登录结束 -->
				</ul>
			</div>
			<!-- 右侧结束 -->
		</div>
	</div>
<!-- 头部灰色区域结束 -->
<!-- 中间主体区域 -->
	



<!-- 头部灰色区域结束 -->
<!-- 中间主体区域 -->
	<div id="main">
	<!-- logo区域 -->
<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
          <script type="text/javascript" src='http://localhost/Gshop/template/js/jquery-1.7.2.min.js'></script>
         <script type="text/javascript" src='http://localhost/Gshop/template/js/jd.js'></script>
          <link rel="stylesheet" type="text/css" href="http://localhost/Gshop/template/css/logo.css">
    </head>
    <body>
<!-- logo区域开始  -->
    <div class="main_logo ">
      <img src="http://localhost/Gshop/template/images/logo.png" alt="" class="logo" />
      <div class="sousuo">
        <form action="">
          <input type="text" class="shuru fl" value='平板电脑' />
          <input type="submit" class="tijiao fr" value="搜索" />
        </form>
      </div>
      <p >
        <span class='fl'>热门搜索：</span>
<!-- 热门搜索区域开始 -->
      <?php $hd["list"]["h"]["total"]=0;if(isset($hot) && !empty($hot)):$_id_h=0;$_index_h=0;$lasth=min(1000,count($hot));
$hd["list"]["h"]["first"]=true;
$hd["list"]["h"]["last"]=false;
$_total_h=ceil($lasth/1);$hd["list"]["h"]["total"]=$_total_h;
$_data_h = array_slice($hot,0,$lasth);
if(count($_data_h)==0):echo "";
else:
foreach($_data_h as $key=>$h):
if(($_id_h)%1==0):$_id_h++;else:$_id_h++;continue;endif;
$hd["list"]["h"]["index"]=++$_index_h;
if($_index_h>=$_total_h):$hd["list"]["h"]["last"]=true;endif;?>

        <?php if($hd['list']['h']['first']){?>
          <a href="<?php echo U('category',array('cid'=>$h[cid]));?>" class="hong"><?php echo $h['cname'];?></a>
          <?php  }else{ ?>
           <a href="<?php echo U('category',array('cid'=>$h[cid]));?>"><?php echo $h['cname'];?></a>
        <?php }?>
      <?php $hd["list"]["h"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
<!-- 热门搜索区域结束 -->
      </p>

      <div class="jiesuan">
        <div class="jie_kong_da">
          <?php if(!empty($_SESSION['cart']['goods'])){?>
                <ul>
                  <?php $hd["list"]["ca"]["total"]=0;if(isset($cart) && !empty($cart)):$_id_ca=0;$_index_ca=0;$lastca=min(1000,count($cart));
$hd["list"]["ca"]["first"]=true;
$hd["list"]["ca"]["last"]=false;
$_total_ca=ceil($lastca/1);$hd["list"]["ca"]["total"]=$_total_ca;
$_data_ca = array_slice($cart,0,$lastca);
if(count($_data_ca)==0):echo "";
else:
foreach($_data_ca as $key=>$ca):
if(($_id_ca)%1==0):$_id_ca++;else:$_id_ca++;continue;endif;
$hd["list"]["ca"]["index"]=++$_index_ca;
if($_index_ca>=$_total_ca):$hd["list"]["ca"]["last"]=true;endif;?>

                  <li>
                    <div class="img"><img src="http://localhost/Gshop/<?php echo $ca['index_pic'];?>" alt=""></div>
                      <div class="name"><a href="<?php echo U('content',array('gid'=>$ca[gid]));?>"><?php echo $ca['gname'];?></a></div>
                  </li>
                <?php $hd["list"]["ca"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                </ul>
            <?php  }else{ ?>
                <span class='gou'></span>
                <span class='gouwen' >购物车中还没有商品，赶紧选购吧！</span>
          <?php }?>
        </div>
        <div class="jie">
          <a href="<?php echo U('cart/index');?>" class="fl go">去购物车结算</a><span class='youjiao fl'></span>
        </div>
      </div>   
    </div>
<!-- logo区域结束 -->
    </body>
</html>
	<!--logo区域结束  -->
	<!-- 导航区域 -->
<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
          <script type="text/javascript" src='http://localhost/Gshop/template/js/jquery-1.7.2.min.js'></script>
          <script type="text/javascript" src='http://localhost/Gshop/template/js/fenlei.js'></script>
          <script type="text/javascript" src='http://localhost/Gshop/template/js/head.js'></script>
    </head>
    <body>
<div class="menu">
      <div class="menu_l fl ">
        <a href="" class="quan_fen">全部商品分类</a>
          <!-- 左分类以及轮换图 -->
          <!-- 左侧 -->
            <div class="middle_l fl">
              <ul>
<!-- 一层栏目的循环开始 -->
              <?php $hd["list"]["cate"]["total"]=0;if(isset($categoryInfo) && !empty($categoryInfo)):$_id_cate=0;$_index_cate=0;$lastcate=min(1000,count($categoryInfo));
$hd["list"]["cate"]["first"]=true;
$hd["list"]["cate"]["last"]=false;
$_total_cate=ceil($lastcate/1);$hd["list"]["cate"]["total"]=$_total_cate;
$_data_cate = array_slice($categoryInfo,0,$lastcate);
if(count($_data_cate)==0):echo "";
else:
foreach($_data_cate as $key=>$cate):
if(($_id_cate)%1==0):$_id_cate++;else:$_id_cate++;continue;endif;
$hd["list"]["cate"]["index"]=++$_index_cate;
if($_index_cate>=$_total_cate):$hd["list"]["cate"]["last"]=true;endif;?>

                <li>
                  <div class="youkuang">
                                <div class="youkuang_l">
            <!-- 二层栏目的循环开始 -->
                                  <?php $hd["list"]["cat"]["total"]=0;if(isset($cate['_data']) && !empty($cate['_data'])):$_id_cat=0;$_index_cat=0;$lastcat=min(1000,count($cate['_data']));
$hd["list"]["cat"]["first"]=true;
$hd["list"]["cat"]["last"]=false;
$_total_cat=ceil($lastcat/1);$hd["list"]["cat"]["total"]=$_total_cat;
$_data_cat = array_slice($cate['_data'],0,$lastcat);
if(count($_data_cat)==0):echo "";
else:
foreach($_data_cat as $key=>$cat):
if(($_id_cat)%1==0):$_id_cat++;else:$_id_cat++;continue;endif;
$hd["list"]["cat"]["index"]=++$_index_cat;
if($_index_cat>=$_total_cat):$hd["list"]["cat"]["last"]=true;endif;?>

                                          <div class="youkuang_l_div">
                                                      <div class="youkuang_l_div_zi">
                                                                  <div>
                                                                    <a href=""><?php echo $cat['cname'];?></a>
                                                                  </div>
                                                        <ul>
                                                            <?php $hd["list"]["ca"]["total"]=0;if(isset($cat['_data']) && !empty($cat['_data'])):$_id_ca=0;$_index_ca=0;$lastca=min(1000,count($cat['_data']));
$hd["list"]["ca"]["first"]=true;
$hd["list"]["ca"]["last"]=false;
$_total_ca=ceil($lastca/1);$hd["list"]["ca"]["total"]=$_total_ca;
$_data_ca = array_slice($cat['_data'],0,$lastca);
if(count($_data_ca)==0):echo "";
else:
foreach($_data_ca as $key=>$ca):
if(($_id_ca)%1==0):$_id_ca++;else:$_id_ca++;continue;endif;
$hd["list"]["ca"]["index"]=++$_index_ca;
if($_index_ca>=$_total_ca):$hd["list"]["ca"]["last"]=true;endif;?>

                                                          <li><span>|</span><a href="<?php echo U('index/index/category',array('cid'=>$ca['cid']));?>"><?php echo $ca['cname'];?></a></li>
                                                            <?php $hd["list"]["cate"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
                                                        </ul>
                                                      </div>
                                          </div>

                                  <?php $hd["list"]["cat"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
            <!-- 二层栏目循环的结束 -->
                           </div>
                  </div>
                  <div class="bao">
                    <span></span>
                    <div class="kong"></div>
                    <div class="kongshang"><a href=""><?php echo $cate['cname'];?></a></div>
                  </div>
                </li>
            <?php $hd["list"]["ca"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
<!-- 一层栏目循环结束 -->
              </ul>
            </div>
          <!-- 左侧结束 -->
          <!-- 左分类以及轮换图结束-->
      </div>

      
      <div class="menu_r fl">
        <a href="http://localhost/Gshop" class="active">首页</a>
        <a href="<?php echo U('category',array('cid'=>20));?>">数码相机</a>
        <a href="<?php echo U('category',array('cid'=>44));?>">笔记本</a>
      </div>
    </div>
    </body>
</html>
	<!-- 导航区域结束 -->
	<!-- 面包屑导航 -->
	<div id="mian">
		<a href="<?php echo U('category',array('cid'=>$category[cid]));?>" class="da"><?php echo $category['cname'];?></a>
	</div>
	<!-- 面包屑导航结束 -->


	<!-- 放大镜区域	 -->
		<div id="fang">
	<!-- 左边区域 -->
		<div class="fang_l">
			<div class="tu">
				<span></span>
				<a href=""><img src="http://localhost/Gshop/<?php echo $pic['medium'];?>" alt="" /></a>
				<div class="gai"></div>
				<div class="large">
					<img src="http://localhost/Gshop/<?php echo $pic['big'];?>" alt="" />
				</div>
			</div>
			<div class="lie">
				<div class="lie_l">
					
				</div>
				<div class="lie_m">
					<ul>
						<li><img src="http://localhost/Gshop/<?php echo $pic['big'];?>" alt="" /></li>
						<li><img src="http://localhost/Gshop/<?php echo $pic['big'];?>" alt="" /></li>
						<li><img src="http://localhost/Gshop/<?php echo $pic['big'];?>" alt="" /></li>
					</ul>
				</div>
				<div class="lie_r">
					
				</div>
			</div>

		</div>
	<!-- 左边区域结束 -->
<!-- 商品规格属性的显示 -->
	<!-- 右边区域开始 -->
		<div class="fang_r">
			<h2 class="p1"><?php echo $goods['gname'];?></h2>
			<h2 class="p2"><?php echo $goods['description'];?></h2>
			<!-- <p>商品编号：686571</p> -->
			<p>京 东 价：<span class='red_da price'>￥<?php echo $stock['price'];?></span> </p>

			<p>商品评分:（<a href="">已有3621人评价</a>）</p>
			
			<p>服　　务：由 京东 发货并提供售后服务。支持:</p>　　　
			<p>温馨提示：<span class='red'>北京地区支持礼品包装</span>  详情 >></p>




<!-- 规格属性区域 -->
			<!-- 属性区域 -->
		<?php $hd["list"]["attr"]["total"]=0;if(isset($attrClass) && !empty($attrClass)):$_id_attr=0;$_index_attr=0;$lastattr=min(1000,count($attrClass));
$hd["list"]["attr"]["first"]=true;
$hd["list"]["attr"]["last"]=false;
$_total_attr=ceil($lastattr/1);$hd["list"]["attr"]["total"]=$_total_attr;
$_data_attr = array_slice($attrClass,0,$lastattr);
if(count($_data_attr)==0):echo "";
else:
foreach($_data_attr as $key=>$attr):
if(($_id_attr)%1==0):$_id_attr++;else:$_id_attr++;continue;endif;
$hd["list"]["attr"]["index"]=++$_index_attr;
if($_index_attr>=$_total_attr):$hd["list"]["attr"]["last"]=true;endif;?>

			<p class="chose"><span>选择<?php echo $attr['attr_name'];?>：</span>
				<?php $hd["list"]["at"]["total"]=0;if(isset($attr['attr']) && !empty($attr['attr'])):$_id_at=0;$_index_at=0;$lastat=min(1000,count($attr['attr']));
$hd["list"]["at"]["first"]=true;
$hd["list"]["at"]["last"]=false;
$_total_at=ceil($lastat/1);$hd["list"]["at"]["total"]=$_total_at;
$_data_at = array_slice($attr['attr'],0,$lastat);
if(count($_data_at)==0):echo "";
else:
foreach($_data_at as $key=>$at):
if(($_id_at)%1==0):$_id_at++;else:$_id_at++;continue;endif;
$hd["list"]["at"]["index"]=++$_index_at;
if($_index_at>=$_total_at):$hd["list"]["at"]["last"]=true;endif;?>

				<!-- 如果商品选择了这个属性，我们就让他显示出来 -->
				 <?php
				 	foreach($goods_attr as $attr){
				 		if($at['av_name']==$attr['av_name']){?>
						   <?php if(in_array($attr['av_id'],$stockData)){?>
					 		<a href="javascript:;" attr="<?php echo $attr['avid'];?>" class="active" onclick="searchAttr(this)"><?php echo $at['av_name'];?></a>
					 	   <?php  }else{ ?>
					 	   	<a href="javascript:;" attr="<?php echo $attr['avid'];?>" onclick="searchAttr(this)"><?php echo $at['av_name'];?></a>
					 	   <?php }?>
				<?php
				 		}
				 	}
				 ?>
				<?php $hd["list"]["attr"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
			</p>
		<?php $hd["list"]["at"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
<!-- 属性区域结束 -->
<!-- 规格属性区域结束 -->
		<form action="<?php echo U('cart/addCart',array('spec'=>Q('spec')));?>" method="post">
			<!-- 购买数量的操作 -->

			<div class="chose">购买数量：<span class="del">-</span><input type="text" name="num" value="1" id=""  class='num'/><span class="add">+</span></div>


			<p>京东服务：延长保修2年 ￥390.00更多摔碰管修1年 ￥310.00详情</p>
			<p>已选择“黑”，“18-105mm 镜头套机”</p>
			

			<!-- 对购物车的操作开始 -->
			<p>
				<input type="hidden" name="stid" value="<?php echo $goods[st_id];?>"  id="" />
				<input type="hidden"  name="price" value="<?php echo $goods[price];?>"/>
				<input type="submit" value="加入购物车" class="jia" style="background:red; width:100px;height:40px;border-radius:10px;cursor:pointer;font-size:18px;color:white"/>
			</p>
			</form>
			<!-- 对购车的操作结束 -->
		</div>
	<!-- 右边区域结束-->
<!-- 商品规格的显示结束 -->
<!-- 商品数量的操作开始 -->
<script>
//当数量发生改变的时候，商品的总价格自动变化
 function price(){
 	var num=$("input[name='num']").val();
	var price=num*<?php echo $stock['price'];?>;
	$('.price').text('￥'+price+'.00');
 }
//触发按键的事件
$("input[name='num']").keyup(function(){
	var str=$(this).val();
	// alert(str);
	if(str.indexOf('-')>=0){
		$(this).val(1);
	}
});
	
//点击的情况
// 点击减少的时候，减少
	var c=1;
	$(".del").click(function(){
		c--;
		if(c==0){
			c=1;
		}
		$("input[name='num']").val(c);
		//获得相应的价格
		price();
	})
// 点击增加的时候，增加
	$(".add").click(function(){
		c++;
		$("input[name='num']").val(c);
		//获得相应的价格
		price();
	})
</script>
<!-- 商品数量的操作结束 -->

	</div>
</div>
	<!-- 放大镜区域结束 -->
	<!-- 主体内容区域 -->
	<div class='content'>
	<!-- 	<div class="left">
			<div class="top"></div>
		</div> -->
		<div class="right">
			<div class="top">商品详细介绍</div>
			<?php echo $goods['body'];?>
		</div>
	</div>
	<!-- 主体区域结束 -->


</body>
</html>

